<%
  @path = "/var/www/index.html"
  tools_host = rubber_instances.for_role('web_tools').first
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
		<title>Rubber Admin Tools</title>
	</head>
	<body>
		<h1>Rubber Admin Tools</h1>
		<ul>

      <%
        tools_html_path = "/var/www"
        tools_html_prefix = "#{tools_html_path}/rubber-web-tools-"
        Dir["#{tools_html_prefix}*.html"].each do |tools_file|
          tool_path = tools_file.gsub(tools_html_path, '')
          tool_name = tools_file.gsub(tools_html_prefix, '').split('.').first
          tool_name = tool_name.capitalize
      %>
          <li><a href="<%= tool_path %>"><%= tool_name %></a></li>
      <% end %>

      <%
        # add the ip aliases for web tools hosts so we can map internal tools
        # to their own vhost to make proxying easier (rewriting url paths for
        # proxy is a real pain, e.g. '/graphite/' externally to '/' on the
        # graphite web app)
        Array(rubber_env.web_tools_proxies).each do |name, settings|
      %>
        <li><a href="https://<%= name %>-<%= tools_host.full_name %>:<%= rubber_env.web_tools_ssl_port %><%= settings.path || '/' %>"><%= name.capitalize %></a></li>
      <% end %>

		</ul>
	</body>
</html>
